﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PFMConfigurations;
using PFMHandlers;

namespace PFMKernels
{
   public  class PFMCoordinator
    {
       PFMConfigurationManager o_ConfigurationsManager = null;
   
        PFMTaskDispatcher o_FDispatcher = null;
        public PFMCoordinator()
        {
            o_ConfigurationsManager = new PFMConfigurations.PFMConfigurationManager();
            o_FDispatcher = new PFMTaskDispatcher();
            DoSetups();
        }
       protected void DoSetups()
       {
           try
           {
               //o_ConfigurationsManager.LoadTargets();
               //o_ConfigurationsManager.LoadSchedules();
           }
           catch (Exception ex)
           {
               throw ex;
           }
       }
       public void DoSpecifiedTask(Target aTarget)
       {
           o_FDispatcher.DoSpecifiedTask(this.o_ConfigurationsManager,aTarget);
       }
       public void DoScheduledTask(DateTime aDT)
       {
           List<Schedule> schedulesList=o_ConfigurationsManager.FindScheduleds(aDT);
           try
           {
               o_FDispatcher.DoScheduledTask(o_ConfigurationsManager, schedulesList);
           }
           catch(Exception ex)
           {
               throw ex;
           }

       }
       public PFMConfigurationManager ConfigurationsManager
       {
           get { return o_ConfigurationsManager; }
       }
       
    }
}
